package app

import (
	// "fmt"
	"github.com/kataras/iris/v12"
	"github.com/kataras/iris/v12/sessions"
)

// 登录判断的中间件
func AuthorizeMid(ctx iris.Context) {

	session := sessions.Get(ctx)
	hasLogined := session.Get(HasLogin)

	if hasLogined != nil && hasLogined.(bool) {
		ctx.Next()
		return
	}

	ctx.StopWithStatus(iris.StatusUnauthorized)
}
